//
//  ViewController.swift
//  Dice
//
//  Created by cao on 2024/8/15.
//

import UIKit

class ViewController: UIViewController {
    
    var num1: Int = 0
    var num2: Int = 0
    
    @IBOutlet weak var diceview2: UIImageView!
    @IBOutlet weak var diceview1: UIImageView!
    
    func updateimage () {
        num1 = Int.random(in: 1...6)
        num2 = Int.random(in: 1...6)
        
        var photp1: String = "dice\(num1)"
        var photp2: String = "dice\(num2)"
        
        diceview1.image = UIImage(named: photp1)
        diceview2.image = UIImage(named: photp2)
    }
    
    @IBAction func roll(_ sender: Any) {
        updateimage()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        updateimage()
    }
    
    override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
        updateimage()
    }


}

